package ckf.man.practice.controller;

import ckf.man.practice.entity.SchemeNew;
import ckf.man.practice.service.SchemeNewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/scheme_new")
public class SchemeNewController {
    @Autowired
    private SchemeNewService service;

    @GetMapping("/get")
    public List<SchemeNew> get(){
        return service.list();
    }


    @PostMapping("/getById")
    public SchemeNew getById(@RequestBody Map<String,Integer> data){
        return service.getById(data.get("id"));
    }

    @PostMapping("/getByEquipment")
    public List<SchemeNew> getByEquipment(@RequestBody Map<String,Integer> data){
        return service.selectByEquipment(data.get("equipment_id"));
    }

    @PostMapping("/getByLateralLine")
    public List<SchemeNew> getByLateralLine(@RequestBody Map<String,Integer> data){
        return service.selectByLateralLine(data.get("lateralLine_id"));
    }

    @PostMapping("/getByEquipmentAndLateralLine")
    public List<SchemeNew> getByEquipmentAndLateralLine(@RequestBody Map<String,Integer> data){
        return service.selectByEquipmentAndLateralLine(data.get("equipment_id"),data.get("lateralLine_id"));
    }
}
